package main.java.listener;

import java.util.Map;
import java.util.logging.Logger;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import main.java.bean.XMLBean;
import main.java.constant.Constant;
import main.java.util.XMLParse;

public class ActionListener implements ServletContextListener {

	public static Logger logger = Logger.getLogger("ActionListener");
	
	public void contextDestroyed(ServletContextEvent arg0) {
		logger.info(Constant.contextDestroyed);

	}

	public void contextInitialized(ServletContextEvent arg0) {
		ServletContext servletContext = arg0.getServletContext();
		String xmlPath = servletContext.getInitParameter("struts-config");
		String realPath = servletContext.getRealPath("/");
		Map<String, XMLBean> map = XMLParse.parseXML(realPath+xmlPath);
		servletContext.setAttribute("struts", map);
		logger.info(Constant.contextInitialized);
	}

}
